<template>
  <div>
    <a-button type="primary" @click="focusOnWorkClick">关注工作</a-button>
  </div>
</template>

<script lang="ts" setup>
  import { defineProps } from 'vue';
  import { Message } from '@arco-design/web-vue';
  import { putFocusOnWork } from '@/api/system/common';

  const props = defineProps({
    params: {
      type: Object,
      default: null,
    },
  });

  const focusOnWorkClick = async () => {
    const par = {
      id: props.params ? props.params.id : '',
    };
    try {
      const res = (await putFocusOnWork(par)) as any;
      console.log(res);
      if (res.code === 200) {
        Message.success('已成功关注该任务！');
      } else {
        Message.error('关注任务失败！');
      }
    } catch (error) {
      Message.error('关注任务失败！');
    }
  };
</script>
